package cn.wolfcode.wolf2w.business.controller;

import cn.wolfcode.wolf2w.business.api.RemoteDestinationService;
import cn.wolfcode.wolf2w.business.api.domain.Destination;
import cn.wolfcode.wolf2w.business.api.domain.Reply;
import cn.wolfcode.wolf2w.business.mapper.QuestionseMapper;
import cn.wolfcode.wolf2w.business.mapper.ReplyMapper;
import cn.wolfcode.wolf2w.common.core.domain.R;
import cn.wolfcode.wolf2w.common.security.annotation.InnerAuth;
import cn.wolfcode.wolf2w.business.api.domain.Questionse;
import cn.wolfcode.wolf2w.business.query.QuestionseQuery;
import cn.wolfcode.wolf2w.business.test.service.IQuestionseService;
import cn.wolfcode.wolf2w.member.api.RemoteUserInfoService;
import cn.wolfcode.wolf2w.member.api.domain.UserInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 问答 Controller
 * 
 * @author SQM
 * @date 2024-11-18
 */
@RestController
@RequestMapping("destinationDoubt")
public class QuestionseController {
    @Autowired
    private IQuestionseService questionseService;

    @Autowired
    private RemoteDestinationService remoteDestinationService;




    /**
     * 问答详情
     */
    @GetMapping("/detail/{id}")
    public R<Questionse> detail(@PathVariable Long id) {
        Questionse questionse = questionseService.getById(id);
        return R.ok(questionse);
    }
    /**
     * 问答 列表
     */
    @GetMapping("/query")
    public R<IPage<Questionse>> query( QuestionseQuery qo) {
        IPage<Questionse> page = questionseService.queryPage(qo);
        return R.ok(page);
    }
    @PostMapping("/create")
    public R<?> create(@RequestBody Questionse qo){
        System.out.println(11111);
        System.out.println(qo);
        questionseService.create(qo);
        return R.ok();
    }

    @GetMapping("/list")
    public R<List<Destination>> list(Integer type) {
        R<List<Destination>> destinationsList = remoteDestinationService.ListByType(type,"inner");
        return destinationsList;
    }


    @GetMapping("/page")
    public R<IPage<Questionse>> page(QuestionseQuery qo) {
        IPage<Questionse> page = questionseService.queryPage(qo);
        System.out.println(page.getRecords());
        return R.ok(page);
    }

    /*****************************************对外暴露Fegin接口**********************************************/
    /**
     * Feign 接口
     */
    @GetMapping("/feign/list")
    public R<List<Questionse>> feignList() {
        return R.ok(questionseService.list());
    }
    @InnerAuth
    @GetMapping("/feign/{id}")
    public R<Questionse> feignGet(@PathVariable Long id) {
        return R.ok(questionseService.getById(id));
    }
}
